home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.cs.arizona.edu
/
ftp.cs.arizona.edu.tar
/
ftp.cs.arizona.edu
/
icon
/
newsgrp
/
group97a.txt
/
000062_icon-group-sender _Mon Mar 3 18:46:44 1997.msg
< prev
next >
Wrap
Internet Message Format
|
2000-09-20
|
1KB
Received: by cheltenham.cs.arizona.edu; Tue, 4 Mar 1997 08:22:45 MST
Date: Mon, 3 Mar 1997 18:46:44 -0600
Message-Id: <199703040046.SAA14304@ns1.cmpu.net>
Mime-Version: 1.0
Content-Type: text/plain
Content-Transfer-Encoding: 7bit
From: gep2@computek.net
Subject: reading reals
To: icon-group@cs.arizona.edu
X-Mailer: SPRY Mail Version: 04.00.06.17
Errors-To: icon-group-errors@cs.arizona.edu
Status: RO
Content-Length: 957
>...What is the Icon analog to the C
programming instruction
> scanf("%f%f", &x, &y); ?
>That is, what is the simplest (or most standard)
way to read two real numbers (with intervening
and/or preceding white space) from a line of
input in Icon ?
If I were doing it in SNOBOL/SPITBOL (S-BOL) I'd probably just use something
like:
RD = "0123456789-." ;* define real digits characters
RECORD FENCE BREAK(RD) SPAN(RD) . X BREAK(RD) SPAN(RD) . Y
One could, of course, easily enough define more demanding patterns which
required more specific formatting and which wouldn't match things like
"4.0.7-.-86", but for straightforward applications the way I proposed it would
probably work fine.
Similar approaches would probably yield similar results in Icon using string
scanning.
If you then need to have X and Y be specifically numeric type, that's easy
enough by:
X = +X
Y = +Y
Gordon Peterson
http://www.computek.net/public/gep2/